# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=jndi-injection-exploit
_pkgname=JNDI-Injection-Exploit
pkgver=10.2dc4018
pkgrel=1
pkgdesc='A tool which generates JNDI links can start several servers to exploit JNDI Injection vulnerability, like Jackson, Fastjson, etc.'
arch=('any')
groups=('blackarch' 'blackarch-exploitation')
url='https://github.com/welk1n/JNDI-Injection-Exploit'
license=('MIT')
depends=('java-runtime')
makedepends=('maven' 'git')
source=("$pkgname::git+https://github.com/welk1n/$_pkgname.git")
sha512sums=('SKIP')

build() {
  cd $pkgname

  mvn clean package -DskipTests
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a target "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec java -jar /usr/share/$pkgname/target/$_pkgname-1.0-SNAPSHOT-all.jar "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

